Globals : Global variables
There are some global variables and global functions predefined for each task in JSRE.
Global Functions
require(modName)
modName
{String} Module name.
Import specified module.
Example
var Tcp = require('tcp');
unbreakable(arrowFunc)
arrowFunc
{Function} Callback.
Run the specified callback function without allowing any interrupt response.
The purpose of using the arrow function is to allow the use of the outer this
object.
Example
unbreakable(() => {
console.log('aaa');
console.log('bbb');
console.log('ccc');
});
synchronize(arrowFunc)
arrowFunc
{Function} Callback.
Run the specified callback function, during which the protection code does not accept multi-tasking preemption. Protected code also needs this method in other tasks, otherwise there is no protection effect.
The purpose of using the arrow function is to allow the use of the outer this
object.
Example
- main.js
synchronize(() => {
console.log('111');
console.log('222');
console.log('333');
});
- task.js
synchronize(() => {
console.log('aaa');
console.log('bbb');
console.log('ccc');
});
The main task is printing a gap of 111
222
333
will not be preempted by other tasks print aaa
bbb
ccc
.
setTimeout(callback, delay[, ...arg])
Please refer to the timer module.
setInterval(callback, delay[, ...arg])
Please refer to the timer module.
setImmediate(callback[, ...arg])
Please refer to the timer module.
clearTimeout(timeout)
Please refer to the timer module.
clearInterval(timeout)
Please refer to the timer module.
clearImmediate(timeout)
Please refer to the timer module.
Standard conversion
EdgerOS 1.5.0 and later versions support.
atob(data)
data
{String} Base64 encoded string.- Returns: {Buffer} The decoded buffer object.
btoa(data)
data
{String | Buffer | ArrayBuffer | TypedArray | Array} Requires base64 encoded source data.- Returns: {String} Base64 encoded string.
Global Modules
Global preloading module, does not need require()
import.
console
Please refer to the console module.
process
Please refer to the process module.
INI
Please refer to the INI module.
Buffer
Please refer to the Buffer module.
Timer
Please refer to the timer module.
Task
Please refer to the Task module.
Global Variables
ARGUMENT
- {String} | {Object}
Current task entry parameter.
exports
- {Any}
Please refer to the module module.
module
- {Object}
Please refer to the module module.